03 / 04

What is AOF rewrite, and what problems can it cause in production?

AOF rewrite compacts the log by replaying the current state. It forks a child process, which triggers copy-on-write (CoW). On a write-heavy instance with large memory, this can spike memory usage (up to 2x) and increase latency as the OS copies dirty pages.

Difficulty: 6/10
Topics: AOF rewrite, performance impact, disk I/O

Scenario Questions

0-2 years experience
  1. 1

    If you enable AOF persistence and the background rewrite process starts, what will you see in the Redis log, and how does it affect write latency for a client issuing SET commands?

  2. 2

    You have a small Redis instance with a 500 MB AOF file. How would you manually trigger an AOF rewrite, and what steps would you take to verify it completed successfully?

  3. 3

    What happens if the AOF rewrite process runs out of disk space on the server?

2-5 years experience
  1. 1

    During a load test, you notice latency spikes when the AOF rewrite kicks in. Walk me through how you would diagnose the root cause and what configuration knobs you might adjust.

  2. 2

    A recent deployment caused the Redis AOF rewrite to fail repeatedly, leading to a growing AOF file. Explain how you would troubleshoot the failure and prevent data loss.

  3. 3

    Explain the trade‑offs between using appendonly yes with auto‑aof‑rewrite‑percentage versus scheduling manual rewrites via BGREWRITEAOF in a production service.

5-8 years experience
  1. 1

    Design a strategy to minimize the impact of AOF rewrites on a high‑throughput write‑heavy Redis cluster that must stay under a 5 ms latency SLA.

  2. 2

    How would you handle a scenario where an AOF rewrite consumes all available memory on a Redis instance, causing the process to be killed? Discuss mitigation and architectural changes.

  3. 3

    Compare the implications of AOF rewrite versus RDB snapshots for disaster recovery in a multi‑region deployment, focusing on recovery time objectives and operational risk.

8+ years experience
  1. 1

    Your organization plans to migrate a legacy monolithic service using Redis AOF persistence to a microservices architecture with separate read/write replicas. How would you redesign the persistence strategy to avoid AOF rewrite bottlenecks while ensuring durability?

  2. 2

    At scale, frequent AOF rewrites can cause I/O contention across many nodes. Propose a cross‑team policy and tooling approach to coordinate rewrite windows, monitoring, and fallback mechanisms.

  3. 3

    Discuss the long‑term maintenance considerations of keeping AOF rewrite enabled in a system that must retain ten years of audit logs. What architectural patterns could you employ to balance storage cost, compliance, and performance?

Follow-up Questions

  • What metrics would you monitor while an AOF rewrite is in progress?
  • How do you decide appropriate values for auto‑aof‑rewrite‑percentage and auto‑aof‑rewrite‑min‑size?
  • If a rewrite fails, what steps do you take to ensure data durability?